package cn.biplam.front.component.view.systemManage.sysprivi.user.manage.del;

import cn.biplam.common.bean.systemManage.privi.UserManageBean;
import cn.biplam.common.paramters.TreeParam;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.KvMap;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.component.ComponentBase;
import cn.biplam.front.component.view.systemManage.sysprivi.user.UserManage;
import cn.biplam.front.component.view.systemManage.sysprivi.user.manage.navi.UserNavi;
import cn.biplam.front.html.HtmlDiv;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.htmlscript.script.ScriptTreeNew;
import cn.biplam.front.template.control.Confirm;

/**
 *  删除用户
 * @author XiaoRuxing Dec 4, 20099:51:24 AM
 * @version 1.0
 */
public class DelUser extends ComponentBase{

	public DelUser(UserInfo user, String homeUrl, String recordId,
			KvMap<String, String> params) {
		super(user, homeUrl, recordId, params);
	}

	/**
	 *  
	 * @return 删除用户操作界面
	 * @throws ErrorMessage 
	 */
	public HtmlWindow panel() throws ErrorMessage{
		String recordId = params.getByKey(TreeParam.NODE_ID);
//		String userName = params.getByKey(TreeParam.NODE_NAME);
		Confirm delete = new Confirm("确定删除用户"+""+"?",recordId, params.getByKey(TreeParam.TREE_PCID));
		delete.putAddParams(TreeParam.NODE_CONTARINER_ID, params.getByKey(TreeParam.NODE_CONTARINER_ID));
		delete.bind(UserManage.User_Del_Submit);
		return delete.get();
	}
	
	/**
	 *  删除用户提交
	 * @return 删除后刷新脚本
	 * @throws ErrorMessage 
	 */
	public HtmlWindow submit() throws ErrorMessage{
		UserManageBean opt = UserManageBean.getNewInstance(mUser.getUserID());
		opt.delUser(recordId,false);
		String script = ScriptTreeNew.getRefreshDelete(params.getByKey(TreeParam.NODE_CONTARINER_ID), 
				UserNavi.Expand);
		HtmlWindow win = new HtmlDiv();
		win.bind(script);
		return win;
	}
}
